package com.rwaste.worker.service.impl;

import com.rwaste.commonutils.Msg;
import com.rwaste.commonutils.R;
import com.rwaste.worker.entity.BasicInfo;
import com.rwaste.worker.mapper.BasicInfoMapper;
import com.rwaste.worker.service.BasicInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ly
 * @since 2021-09-25
 */
@Service
public class BasicInfoServiceImpl extends ServiceImpl<BasicInfoMapper, BasicInfo> implements BasicInfoService {
    @Autowired
    private BasicInfoMapper basicInfoMapper;
    //注册方法
    @Override
    public boolean saveWorkerBaseInfo(BasicInfo basicInfo) {

        boolean b = basicInfoMapper.saveWorkerInfo(basicInfo);

        if(b){
            return true;
        }
        return false;
    }

    //登录方法
    @Override
    public BasicInfo findBaseInfo(BasicInfo basicInfo) {
    //String mobile = basicInfo.getMobile();
    //String password = basicInfo.getPassword();

        BasicInfo res =  basicInfoMapper.findWorker(basicInfo);
        return res;
    }

    //根据id 查询 worker 信息
    @Override
    public BasicInfo findWorkerByid(String id) {
        BasicInfo workerById = baseMapper.findWorkerById(id);
        return workerById;
    }

    @Override
    public BasicInfo findWorkerByPassword(String mobile, String password) {
        BasicInfo workerByPassword = baseMapper.findWorkerByPassword(mobile, password);
        return workerByPassword;
    }

    @Override
    public boolean freezeWorkerById(String id) {
        boolean result =  baseMapper.freezeWorkerById(id);
        return result;
    }

    @Override
    public boolean thawWorkerById(String id) {
        boolean result = baseMapper.thawWorkerById(id);
        return result;
    }

    @Override
    public boolean delWorker(String id) {
        boolean result = baseMapper.delWoeker(id);
        return result;
    }


}
